package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;

class zud {
   private Workbook d = null;
   private com.aspose.cells.b.a.d.zm e = null;
   com.aspose.cells.a.f.zj a = null;
   zok b = null;
   private boolean f = false;
   com.aspose.cells.a.f.zi c = null;
   private int g = 6;
   private OoxmlSaveOptions h;
   private zty i = null;

   zud(Workbook var1, com.aspose.cells.b.a.d.zm var2, int var3, OoxmlSaveOptions var4) {
      this.d = var1;
      this.e = var2;
      this.g = var3;
      if (var3 == 9 || var3 == 7 || var3 == 10) {
         this.f = true;
      }

      this.d.setFileFormat(6);
      this.h = var4;
   }

   void a() throws Exception {
      this.d.getWorksheets().b().a();
      this.f();

      try {
         this.y();
         this.v();
         this.g();
         this.d();
         this.c();
         this.b();
         this.u();
         this.w();
         this.t();
         this.j();
         this.s();
         this.o();
         this.p();
         this.n();
         this.i();
         this.l();
         this.i = new zty(this.d, this.b.d);
         this.k();
         this.r();
         this.q();
         this.m();
         this.h();
         this.e();
         this.a.f_();
         this.d.getWorksheets().b().b();
         this.d.b(this.e);
      } finally {
         if (this.d.b != null && this.d.b.b != null) {
            this.d.b.b.a();
         }

      }

   }

   private void g() throws Exception {
      if (this.b.a.getRibbonXml() != null && this.b.a.getRibbonXml().length() > 0) {
         String var1 = this.b.C;
         zcfx var2 = zasr.a(var1, this.a, true);
         var2.d(this.b.a.getRibbonXml());
         var2.e();
      }

   }

   private void h() throws Exception {
      if (this.d.hasMacro() && this.f) {
         VbaProject var1 = this.d.getWorksheets().l;
         boolean var2 = false;
         if (var1.p != null) {
            var2 = this.a(var1.p, var1.q);
         }

         if (!var2) {
            com.aspose.cells.b.a.d.zm var3 = var1.a((zvh)null);
            if (var3 != null) {
               int var4 = (int)var3.h();
               byte[] var5 = new byte[var4];
               var3.a(var5, 0, var4);
               var3.a();
               String var6 = "xl/vbaProject.bin";
               com.aspose.cells.a.f.zh var7 = this.a.a(var6);
               var7.a(DateTime.getNow());
               this.a.a(var7);
               this.a.b(var5, 0, var5.length);
               this.a.b();
            }
         }

      }
   }

   private void a(zqc var1) throws Exception {
      String var2 = com.aspose.cells.b.a.d.zk.b(var1.d);
      String var3 = "xl/pivotCache/" + var2;
      this.a(var3, var3, false);
      String var4 = "xl/pivotCache/_rels/" + var2 + ".rels";
      this.a(var4, var4, false);
      if (this.c != null) {
         if (this.c.a(var4, true) != -1) {
            zcfw var5 = zasr.a(this.c, var4, true);
            HashMap var6 = zajh.b(var5);
            var5.c();
            if (var6 != null && var6.size() > 0) {
               Iterator var7 = var6.values().iterator();

               while(var7.hasNext()) {
                  zqe var8 = (zqe)var7.next();
                  if (var8 != null) {
                     String var9 = var8.e;
                     var9 = "xl/pivotCache/" + var9;
                     this.a(var9, var9, false);
                  }
               }
            }
         }

      }
   }

   private void i() throws Exception {
      ArrayList var1 = this.b.h;
      if (var1 != null) {
         Iterator var2 = var1.iterator();

         while(true) {
            while(var2.hasNext()) {
               zqc var3 = (zqc)var2.next();
               zauk var4 = var3.a;
               if (var4.E != null) {
                  this.a(var3);
               } else {
                  String var5;
                  String var6;
                  String var7;
                  if (var3.f != null) {
                     String var8 = "";
                     int var9 = var3.f.indexOf(".");
                     if (var9 != -1) {
                        var8 = var3.f.substring(0, 0 + var9);
                        var5 = "xl/pivotCache/" + var8 + ".xml";
                        var6 = "xl/pivotCache/_rels/" + var8 + ".xml.rels";
                        var7 = "xl/pivotCache/pivotCacheRecords" + var8.substring(20) + ".xml";
                     } else {
                        var5 = "xl/pivotCache/" + var3.f;
                        var6 = "xl/pivotCache/_rels/" + var3.f + ".rels";
                        var7 = "xl/pivotCache/pivotCacheRecords" + var3.f.substring(20);
                     }
                  } else {
                     var5 = "xl/pivotCache/pivotCacheDefinition" + var3.g + ".xml";
                     var6 = "xl/pivotCache/_rels/pivotCacheDefinition" + var3.g + ".xml.rels";
                     var7 = "xl/pivotCache/pivotCacheRecords" + var3.g + ".xml";
                  }

                  ztp var16 = new ztp(var4);
                  zcfx var17 = zasr.a(var5, this.a, true);
                  var16.a(var17);
                  var17.e();
                  if (var4.C != null && var4.C.size() > 0) {
                     ArrayList var18 = new ArrayList();

                     String var12;
                     for(Iterator var11 = var4.C.keySet().iterator(); var11.hasNext(); com.aspose.cells.b.a.a.ze.a(var18, var4.C.get(var12))) {
                        var12 = (String)var11.next();
                        zqe var13 = (zqe)var4.C.get(var12);
                        int var14 = var13.e.indexOf(".");
                        if (var14 != -1) {
                           String var15 = var13.e.substring(0, 0 + var14) + this.b.p;
                           var13.e = var15;
                        }
                     }

                     int var20 = var5.lastIndexOf("/");
                     var5 = "xl/pivotCache/_rels/" + var5.substring(var20 + 1) + ".rels";
                     var17 = zasr.a(var5, this.a, true);
                     ztt.a(var17, var18);
                     var17.e();
                  } else {
                     String var10 = "pivotCacheRecords" + var3.g + ".xml";
                     this.a(var6, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords", var10, (String)null);
                  }

                  if (var4.n != null && var4.n.a != null) {
                     ztq var19 = new ztq(var4);
                     var17 = zasr.a(var7, this.a, true);
                     var19.a(var17);
                     var17.e();
                  }
               }
            }

            return;
         }
      }
   }

   private void a(String var1, String var2, String var3, String var4) throws Exception {
      ArrayList var5 = new ArrayList();
      zqe var6 = new zqe("rId1", var2, var3, var4);
      com.aspose.cells.b.a.a.ze.a(var5, (Object)var6);
      zcfx var7 = zasr.a(var1, this.a, true);
      ztt.a(var7, var5);
      var7.e();
   }

   private void j() throws Exception {
      zbqf var1 = this.d.getWorksheets().v();
      if (this.b.t.size() != 0) {
         Iterator var2 = this.b.t.keySet().iterator();

         while(var2.hasNext()) {
            int var3 = (Integer)var2.next();
            zqe var4 = (zqe)this.b.t.get(var3);
            zbqg var5 = var1.a(var3);
            String var6 = var5.k();
            String var7 = "xl/" + var4.e;
            String var8 = "xl/externalLinks/_rels/" + com.aspose.cells.a.c.zt.b(var7) + ".rels";
            if (var5.a() == 0 || var5.a() == 4) {
               String var9 = null;
               String var10 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath";
               if (var5.a() == 4) {
                  String var11 = null;
                  String var12 = null;
                  String[] var13 = new String[]{var11};
                  String[] var14 = new String[]{var12};
                  var5.b(var13, var14);
                  var11 = var13[0];
                  var12 = var14[0];
                  var9 = var12;
                  var10 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
               } else {
                  var9 = var5.l();
               }

               var9 = com.aspose.cells.b.a.zv.a(var9, " ", "%20");
               if (var9 != null && !"".equals(var9)) {
                  this.a(var8, var10, var9, "External");
               }
            }

            zcfx var15 = zasr.a(var7, this.a, true);
            ztk var16 = new ztk(this.b, var5);
            var16.a(var15);
            var15.e();
         }

      }
   }

   private void a(zol var1) throws Exception {
      if (var1.n.a != null) {
         String var2 = "xl/drawings/" + var1.n.b;
         zub var3 = new zub(var1);
         var3.a(this.a, var2);
         String var4 = "xl/drawings/_rels/";
         String var5 = var4 + var1.n.b + ".rels";
         if (var1.n.c.size() > 0) {
            zcfx var6 = zasr.a(var5, this.a, true);
            ztt.a(var6, var1.n.c);
            var6.e();
         }

         int var9 = var1.n.g.size();
         if (var9 != 0) {
            for(int var7 = 0; var7 < var9; ++var7) {
               zom var8 = (zom)var1.n.g.get(var7);
               this.a(var8);
               this.b.a(var8.b);
            }

         }
      }
   }

   private void k() throws Exception {
      for(int var1 = 0; var1 < this.b.c.size(); ++var1) {
         zol var2 = (zol)this.b.c.get(var1);
         this.b(var2);
         if (this.d.getSaveOptions().getClearData()) {
            var2.a.getCells().clear();
         }
      }

   }

   private void b(zol var1) throws Exception {
      Worksheet var2 = var1.a;
      Cells var3 = var2.getCells();
      boolean var4 = var2.t() != null && var2.t().getCount() > 0;

      try {
         var3.d = new zkt(var3, 255);
         if (var4) {
            var3.c = new zkx(var3, 255);
            var3.getRows().b(0);
         }

         if (var1.a.getType() == 1) {
            this.o(var1);
         } else if (var1.a.getType() == 2) {
            this.n(var1);
         }

         this.m(var1);
         this.l(var1);
         this.k(var1);
         this.a(var1);
         this.a(var1.m.f);
         this.j(var1);
         zavb.a(var1.a, false);
         this.h(var1);
         this.f(var1);
         this.d(var1);
         this.e(var1);
         this.g(var1);
         this.c(var1);
         this.i(var1);
      } finally {
         var3.m();
         if (var4) {
            var3.l();
            var3.getRows().b();
         }

      }

      a(this.a, var1);
   }

   static void a(com.aspose.cells.a.f.zj var0, zol var1) throws Exception {
      Iterator var2 = var1.p.iterator();

      while(true) {
         while(true) {
            zpf var3;
            byte[] var4;
            do {
               do {
                  do {
                     if (!var2.hasNext()) {
                        return;
                     }

                     var3 = (zpf)var2.next();
                  } while(var3.a());
               } while(var3.i == null);

               var4 = var3.i.getData();
            } while(var4 == null);

            boolean var5 = true;
            HashMap var6 = null;
            if (var3.i.getType() == 11) {
               UnknownControl var7 = (UnknownControl)var3.i;
               var5 = var7.g == 3;
               var6 = var7.h;
            }

            String var11;
            zqe var13;
            String var15;
            if (var5) {
               var15 = "xl/activeX/activeX" + var3.j + ".bin";
               a(var0, var15, var4, 0, var4.length);
               var15 = "xl/activeX/activeX" + var3.j + ".xml";
               zcfx var16 = zasr.a(var15, var0, true);
               var16.b("ax:ocx");
               byte[] var17 = new byte[16];
               System.arraycopy(var4, 0, var17, 0, var17.length);
               com.aspose.cells.b.a.zh var19 = new com.aspose.cells.b.a.zh(var17);
               var16.a("ax:classid", "{" + com.aspose.cells.b.a.zr.a(var19) + "}");
               var16.a("r:id", "rId1");
               var16.a("xmlns:ax", "http://schemas.microsoft.com/office/2006/activeX");
               var16.a("ax:persistence", "persistStreamInit");
               var16.a("xmlns:r", zase.e);
               var16.b();
               var16.e();
               var11 = "xl/activeX/_rels/activeX" + var3.j + ".xml.rels";
               zcfx var21 = zasr.a(var11, var0, true);
               var13 = new zqe("rId1", "http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary", "activeX" + var3.j + ".bin", (String)null);
               ArrayList var14 = new ArrayList();
               com.aspose.cells.b.a.a.ze.a(var14, (Object)var13);
               ztt.a(var21, var14);
               var21.e();
            } else {
               var15 = "xl/activeX/activeX" + var3.j + ".xml";
               a(var0, var15, var4, 0, var4.length);
               if (var6 != null) {
                  int var8 = 0;
                  ArrayList var9 = new ArrayList();

                  for(Iterator var10 = var6.keySet().iterator(); var10.hasNext(); ++var8) {
                     var11 = (String)var10.next();
                     int var12 = var3.j + var8;
                     var15 = "xl/activeX/activeX" + var12 + ".bin";
                     var4 = (byte[])((byte[])var6.get(var11));
                     a(var0, var15, var4, 0, var4.length);
                     var13 = new zqe(var11, "http://schemas.microsoft.com/office/2006/relationships/activeXControlBinary", "activeX" + var12 + ".bin", (String)null);
                     com.aspose.cells.b.a.a.ze.a(var9, (Object)var13);
                  }

                  String var18 = "xl/activeX/_rels/activeX" + var3.j + ".xml.rels";
                  zcfx var20 = zasr.a(var18, var0, true);
                  ztt.a(var20, var9);
                  var20.e();
               }
            }
         }
      }
   }

   private void c(zol var1) throws Exception {
      Worksheet var2 = var1.a;
      QueryTableCollection var3 = var2.getQueryTables();
      if (var3.getCount() != 0) {
         for(int var4 = 0; var4 < var3.getCount(); ++var4) {
            QueryTable var5 = var3.get(var4);
            String var6 = var5.a;
            if (var6 != null) {
               zcfx var7 = zasr.a(var6, this.a, true);
               zts var8 = new zts(this.b, var5);
               var8.a(var7);
               var7.e();
            }
         }

      }
   }

   private void d(zol var1) throws Exception {
      int var2 = var1.u.size();
      if (var2 != 0) {
         for(int var3 = 0; var3 < var2; ++var3) {
            zoe var4 = (zoe)var1.u.get(var3);
            String var5 = "xl/" + var4.c;
            com.aspose.cells.a.f.zh var6 = this.a.a(var5);
            var6.a(DateTime.getNow());
            this.a.a(var6);
            this.a.b(var4.d, 0, var4.d.length);
            this.a.b();
         }

      }
   }

   private void e(zol var1) throws Exception {
      if (var1.t != null && var1.t.size() != 0) {
         Iterator var2 = var1.t.keySet().iterator();

         while(var2.hasNext()) {
            String var3 = (String)var2.next();
            com.aspose.cells.a.f.zh var4 = this.a.a(var3);
            var4.a(DateTime.getNow());
            this.a.a(var4);
            byte[] var5 = (byte[])((byte[])var1.t.get(var3));
            this.a.b(var5, 0, var5.length);
            this.a.b();
         }

      }
   }

   private void f(zol var1) throws Exception {
      int var2 = var1.o.size();
      if (var2 != 0) {
         for(int var3 = 0; var3 < var2; ++var3) {
            zob var4 = (zob)var1.o.get(var3);
            if (!var4.a.isLink()) {
               byte[] var5 = var4.a.h();
               String var6 = "xl/embeddings/" + var4.e;
               com.aspose.cells.a.f.zh var7 = this.a.a(var6);
               var7.a(DateTime.getNow());
               this.a.a(var7);
               this.a.b(var5, 0, var5.length);
               this.a.b();
            }
         }

      }
   }

   private void g(zol var1) throws Exception {
      if (var1.v.size() != 0) {
         com.aspose.cells.b.a.a.zc var2 = com.aspose.cells.b.a.a.zf.a(var1.v);

         label48:
         while(true) {
            ListObject var3;
            String var6;
            zcfx var7;
            do {
               do {
                  if (!var2.c()) {
                     break label48;
                  }

                  var3 = (ListObject)var2.a();
                  String var4 = (String)var2.b();
                  zqe var5 = zajh.a(var1.h, var4);
                  var6 = "xl" + var5.e.substring(2);
                  var7 = zasr.a(var6, this.a, true);
                  ztz var8 = new ztz(var1, var3);
                  var8.a(var7);
                  var7.e();
               } while(var3.a == null);
            } while(var3.a.size() <= 0);

            ArrayList var9 = new ArrayList();
            Iterator var10 = var3.a.keySet().iterator();

            while(var10.hasNext()) {
               String var11 = (String)var10.next();
               com.aspose.cells.b.a.a.ze.a(var9, var3.a.get(var11));
            }

            int var19 = var6.lastIndexOf("/");
            var6 = "xl/tables/_rels/" + var6.substring(var19 + 1) + ".rels";
            var7 = zasr.a(var6, this.a, true);
            ztt.a(var7, var9);
            var7.e();
            Iterator var20 = var3.a.keySet().iterator();

            while(var20.hasNext()) {
               String var12 = (String)var20.next();
               zqe var13 = (zqe)var3.a.get(var12);
               if (var13.d.equals("http://schemas.openxmlformats.org/officeDocument/2006/relationships/queryTable")) {
                  QueryTable var14 = new QueryTable();
                  String var15 = "xl/queryTables/" + com.aspose.cells.b.a.d.zk.b(var13.e);
                  var14.a = var15;
                  if (var15 != null) {
                     zasr.a(var15, this.a, true);
                     zts var17 = new zts(this.b, var14);
                     var17.a(var7);
                     var7.e();
                  }
               }
            }
         }
      }

      if (var1.x != null) {
         byte[] var18 = var1.a.g.h;
         a(this.a, var1.x, var18, 0, var18.length);
      }

   }

   private void h(zol var1) throws Exception {
      PivotTableCollection var2 = var1.a.b;
      if (var2 != null && var2.getCount() != 0) {
         for(int var3 = 0; var3 < var2.getCount(); ++var3) {
            PivotTable var4 = var2.get(var3);
            int var5 = (Integer)this.b.i.get(var4);
            String var6 = "xl/pivotTables/pivotTable" + var5 + ".xml";
            String var7 = "xl/pivotTables/_rels/pivotTable" + var5 + ".xml.rels";
            if (var4.d != null) {
               zqc var8 = this.b.a(var4.d);
               if (var8 != null) {
                  zcfx var9 = zasr.a(var6, this.a, true);
                  ztr var10 = new ztr(var4, var8.c);
                  var10.a(var9);
                  var9.e();
                  String var11 = "../pivotCache/pivotCacheDefinition" + var8.g + ".xml";
                  this.a(var7, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition", var11, (String)null);
               }
            }
         }

      }
   }

   private void i(zol var1) throws Exception {
      if (var1.y != null) {
         Iterator var2 = var1.y.keySet().iterator();

         while(var2.hasNext()) {
            String var3 = (String)var2.next();
            zqe var4 = (zqe)var1.y.get(var3);
            String var5 = "xl/slicers/" + com.aspose.cells.a.c.zt.b(var4.e);
            zcfx var6 = zasr.a(var5, this.a, true);
            ztw var7 = new ztw(var1.a.d(), var3);
            var7.a(var6);
            var6.e();
         }

      }
   }

   private void l() throws Exception {
      if (this.b.A != null) {
         Iterator var1 = this.b.A.iterator();

         while(var1.hasNext()) {
            zqk var2 = (zqk)var1.next();
            zbmu var3 = var2.d;
            String var4 = var2.b;
            zcfx var5 = zasr.a(var4, this.a, true);
            ztx var6 = new ztx(var3);
            var6.a(var5);
            var5.e();
         }

      }
   }

   private void a(ArrayList var1) throws Exception {
      for(int var2 = 0; var2 < var1.size(); ++var2) {
         znw var3 = (znw)var1.get(var2);
         String var4 = "xl/charts/chart" + zase.y(var3.b) + ".xml";
         zcfx var5 = zasr.a(var4, this.a, true);
         zsz var6 = new zsz(var3);
         var6.a(var5);
         var5.e();
         this.a(var3);
         if (var3.d.size() != 0) {
            this.b(var3);
         }

         if (var3.h != null) {
            byte[] var7 = var3.a.a.a;
            a(this.a, "xl/theme/" + var3.h, var7, 0, var7.length);
         }

         if (var3.f != null) {
            this.c(var3);
         }
      }

   }

   private void a(znw var1) throws Exception {
      int var2 = var1.c.size();
      if (var2 != 0) {
         for(int var3 = 0; var3 < var2; ++var3) {
            zom var4 = (zom)var1.c.get(var3);
            this.a(var4);
            this.b.a(var4.b);
         }

      }
   }

   private void a(znx var1) throws Exception {
      int var2 = var1.j.size();
      if (var2 != 0) {
         for(int var3 = 0; var3 < var2; ++var3) {
            zom var4 = (zom)var1.j.get(var3);
            this.a(var4);
            this.b.a(var4.b);
         }

      }
   }

   private void a(zom var1) throws Exception {
      String var2 = "xl/media/" + var1.b;
      a(this.a, var2, var1.a, 0, var1.a.length);
   }

   static void a(com.aspose.cells.a.f.zj var0, String var1, byte[] var2, int var3, int var4) throws Exception {
      com.aspose.cells.a.f.zh var5 = var0.a(var1);
      var5.a(DateTime.getNow());
      var0.a(var5);
      var0.b(var2, var3, var4);
      var0.b();
   }

   private void b(znw var1) throws Exception {
      int var2 = var1.b;
      String var3 = "xl/charts/_rels/chart" + zase.y(var2) + ".xml.rels";
      zcfx var4 = zasr.a(var3, this.a, true);
      ztt.a(var4, var1.d);
      var4.e();
   }

   private void c(znw var1) throws Exception {
      String var2 = "xl/drawings/" + var1.f.b;
      zcfx var3 = zasr.a(var2, this.a, true);
      zti var4 = new zti(var1.f);
      var4.a(var3);
      var3.e();
      ArrayList var5 = var1.f.c;
      if (var5 != null && var5.size() > 0) {
         String var6 = "xl/drawings/_rels/" + var1.f.b + ".rels";
         var3 = zasr.a(var6, this.a, true);
         ztt.a(var3, var5);
         var3.e();
      }

      this.b.a("/" + var2, "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml");
      if (var1.f.f.size() != 0) {
         this.a(var1.f.f);
      }

   }

   private void j(zol var1) throws Exception {
      zog var2 = var1.l;
      if (var2 != null && var2.c != null && var2.c.size() != 0) {
         String var3 = "xl/drawings/" + var2.b;
         zcfx var4 = zasr.a(var3, this.a, true);
         ztl var5 = new ztl(var1);
         var5.a(var4);
         var4.e();
         if (var2.c != null && var2.c.size() > 0) {
            String var6 = "xl/drawings/_rels/" + var2.b + ".rels";
            var4 = zasr.a(var6, this.a, true);
            ztt.a(var4, var2.c);
            var4.e();
         }

      }
   }

   private void k(zol var1) throws Exception {
      if (var1.m.a != null) {
         String var2 = "xl/drawings/" + var1.m.b;
         String var3 = "xl/drawings/_rels/" + var1.m.b + ".rels";
         zcfx var4 = zasr.a(var2, this.a, true);
         zti var5 = new zti(var1.m);
         var5.a(var4);
         var4.e();
         this.a(var1.m);
         if (var1.m.c != null && var1.m.c.size() > 0) {
            var4 = zasr.a(var3, this.a, true);
            ztt.a(var4, var1.m.c);
            var4.e();
         }

      }
   }

   private void l(zol var1) throws Exception {
      if (var1.c()) {
         String var2 = "xl/" + var1.g;
         zcfx var3 = zasr.a(var2, this.a, true);
         ztb var4 = new ztb(var1);
         var4.a(var3);
         var3.e();
      }
   }

   private void m(zol var1) throws Exception {
      if (var1.h != null && var1.h.size() != 0) {
         String var2 = "xl/worksheets/_rels/sheet" + zase.y(var1.d) + ".xml.rels";
         if (var1.a.getType() == 2) {
            var2 = "xl/chartsheets/_rels/sheet" + zase.y(var1.d) + ".xml.rels";
         }

         zcfx var3 = zasr.a(var2, this.a, true);
         ztt.a(var3, var1.h);
         var3.e();
      }

   }

   private void n(zol var1) throws Exception {
      String var2 = "xl/chartsheets/sheet" + zase.y(var1.d) + ".xml";
      zcfx var3 = zasr.a(var2, this.a, true);
      zta var4 = new zta(var1);
      var4.a(var3);
      var3.e();
   }

   private void o(zol var1) throws Exception {
      String var2 = "xl/worksheets/sheet" + zase.y(var1.d) + ".xml";
      zcfx var3 = zasr.a(var2, this.a, true);
      zuf var4 = new zuf(var1, this.b.d, this.h);
      var4.a = this.i;
      var4.a(var3);
      var3.e();
   }

   private void m() throws Exception {
      zazw var1 = this.d.getWorksheets().k;
      if (var1 != null && var1.getCount() != 0) {
         var1.a(false);
         ztu var2 = new ztu(this.b, this.i);
         String var3 = "xl/revisions/revisionHeaders.xml";
         zcfx var4 = zasr.a(var3, this.a, true);
         var2.a(var4, var1);
         var4.e();
         String var5;
         if (this.b.D.b != null) {
            var5 = "xl/revisions/_rels/revisionHeaders.xml.rels";
            zcfx var6 = zasr.a(var5, this.a, true);
            ztt.a(var6, this.b.D.b);
            var6.e();
         }

         if (var1.n != null) {
            var5 = "xl/revisions/userNames.xml";
            var4 = zasr.a(var5, this.a, true);
            var2.a(var4, var1.n);
            var4.e();
         }

         for(int var8 = 0; var8 < var1.getCount(); ++var8) {
            zazv var9 = var1.a(var8);
            String var7 = "xl/revisions/revisionLog" + zase.y(var8 + 1) + ".xml";
            var4 = zasr.a(var7, this.a, true);
            var2.a(var4, var9);
            var4.e();
         }

      }
   }

   private void n() throws Exception {
      String var1 = "xl/_rels/workbook.xml.rels";
      zcfx var2 = zasr.a(var1, this.a, true);
      ztt.a(var2, this.b.e);
      var2.e();
   }

   private void o() throws Exception {
      String var1 = "xl/theme/theme1.xml";
      zcfx var2 = zasr.a(var1, this.a, true);
      zua var3 = new zua(this.b);
      var3.a(var2);
      var2.e();
      if (this.d.c != null && this.d.c.d != null) {
         String var4 = "xl/theme/_rels/theme1.xml.rels";
         var2 = zasr.a(var4, this.a, true);
         ztt.a(var2, this.d.c.d);
         if (this.d.b == null || this.d.b.k == null || this.d.b.k.size() == 0) {
            Iterator var5 = this.d.c.d.values().iterator();

            while(var5.hasNext()) {
               zqe var6 = (zqe)var5.next();
               if (var6.i != null && "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image".equals(var6.d)) {
                  String var7 = "xl/media/" + com.aspose.cells.a.c.zt.b(var6.e);
                  a(this.a, var7, var6.i, 0, var6.i.length);
               }
            }
         }
      }

   }

   private void p() throws Exception {
      if (this.d.h != null && this.d.h.getCount() != 0) {
         String var1 = "xl/connections.xml";
         zcfx var2 = zasr.a(var1, this.a, true);
         ztc var3 = new ztc(this.b);
         var3.a(var2);
         var2.e();
      }
   }

   private void q() throws Exception {
      String var1 = "xl/sharedStrings.xml";
      zcfx var2 = zasr.a(var1, this.a, true);
      ztv var3 = new ztv(this.b, this.i);
      var3.a(var2);
      var2.e();
   }

   private void r() throws Exception {
      String var1 = "xl/styles.xml";
      zcfx var2 = zasr.a(var1, this.a, true);
      this.i.a(var2);
      var2.e();
   }

   private void s() throws Exception {
      String var1 = "xl/workbook.xml";
      zcfx var2 = zasr.a(var1, this.a, true);
      zue var3 = new zue(this.b);
      var3.a(var2);
      var2.e();
   }

   private void t() throws Exception {
      zto var1 = new zto(this.b);
      var1.a(this.a);
   }

   private void u() throws Exception {
      zte var1 = new zte(this.b.a, this.a);
      var1.a();
   }

   void b() throws Exception {
      if (this.b.h()) {
         String var1 = "docProps/custom.xml";
         zcfx var2 = zasr.a(var1, this.a, true);
         zth var3 = new zth(this.b);
         var3.a(var2);
         var2.e();
      }
   }

   void c() throws Exception {
      String var1 = "docProps/app.xml";
      zcfx var2 = zasr.a(var1, this.a, true);
      ztf var3 = new ztf(this.b);
      var3.a(var2);
      var2.e();
   }

   void d() throws Exception {
      String var1 = "docProps/core.xml";
      zcfx var2 = zasr.a(var1, this.a, true);
      ztg var3 = new ztg(this.b);
      var3.a(var2);
      var2.e();
   }

   private void v() throws Exception {
      String var1 = "_rels/.rels";
      zcfx var2 = zasr.a(var1, this.a, true);
      ztt.a(this.b, var2);
      var2.e();
   }

   void e() throws Exception {
      zcfx var1 = zasr.a("[Content_Types].xml", this.a, true);
      ztd var2 = new ztd(this.b);
      var2.a(var1);
      var1.e();
   }

   private void w() throws Exception {
      XmlMapCollection var1 = this.b.a.getWorksheets().getXmlMaps();
      if (var1 != null && var1.getCount() != 0) {
         String var2 = "xl/xmlMaps.xml";
         zcfx var3 = zasr.a(var2, this.a, true);
         zuh var4 = new zuh(this.b);
         var4.a(var3);
         var3.e();
      }
   }

   private void x() throws Exception {
      if (this.c != null) {
         String var1 = "xl/embeddings";
         Iterator var2 = this.c.iterator();

         while(var2.hasNext()) {
            com.aspose.cells.a.f.zh var3 = (com.aspose.cells.a.f.zh)var2.next();
            if (var3.b().startsWith(var1) && !this.d.b.b(com.aspose.cells.b.a.d.zk.b(var3.b()))) {
               this.a(var3, var3.b());
            }
         }

      }
   }

   private boolean a(String var1, boolean var2) throws Exception {
      boolean var3 = false;
      if (!var2) {
         this.b(var1, "xl/vbaProject.bin");
         var3 = true;
      }

      this.b("xl/_rels/" + com.aspose.cells.b.a.d.zk.b(var1) + ".rels", "xl/_rels/vbaProject.bin.rels");
      znt var4 = this.d.b.c("application/vnd.ms-office.vbaProjectSignature");
      if (var4 != null) {
         String var5 = var4.c;
         if (var5.charAt(0) == '/') {
            var5 = var5.substring(1);
         }

         this.b(var5, var5);
      }

      return var3;
   }

   private void y() throws Exception {
      if (this.d.b != null) {
         this.a("xl/diagrams/");
         this.a("userCustomization/");
         if (this.d.isDigitallySigned()) {
            this.a("_xmlsignatures/");
         }

         if (this.d.getRibbonXml() != null && this.d.getRibbonXml().length() > 0) {
            this.a("customUI/_rels/");
            this.a("customUI/images/");
         }

         this.a("ctrlProps/");
         this.a("xl/model/");
         this.a("xl/timelineCaches/");
         this.a("xl/timelines/");
         this.a("xl/ink/");
         this.b("xl/attachedToolbars.bin", "xl/attachedToolbars.bin");
         this.a("vstoDataStore/");
         this.x();
         this.z();
      }
   }

   private void z() throws Exception {
      if (this.d.b != null && this.d.b.k.size() != 0) {
         ArrayList var1 = this.d.b.k;

         for(int var2 = 0; var2 < var1.size(); ++var2) {
            zpk var3 = (zpk)var1.get(var2);
            this.b(var3.b, var3.c);
            String var4 = zase.ak(var3.b);
            String var5 = zase.ak(var3.c);
            this.a(var4, var5);
         }

      }
   }

   private void a(String var1, String var2) throws Exception {
      if (this.c != null) {
         if (this.c.a(var1, true) != -1) {
            zcfw var3 = zasr.a(this.c, var1, true);
            ArrayList var4 = zajh.a(var3);
            var3.c();
            this.d.b.a((Collection)var4);
            zcfx var5 = zasr.a(var2, this.a, true);
            ztt.a(var5, var4);
            var5.e();
         }

      }
   }

   private void a(String var1) throws Exception {
      this.a(var1, var1, true);
   }

   private void b(String var1, String var2) throws Exception {
      this.a(var1, var2, false);
   }

   private void a(String var1, String var2, boolean var3) throws Exception {
      this.a(var1, var2, var3, (String)null);
   }

   private void a(String var1, String var2, boolean var3, String var4) throws Exception {
      if (this.c != null) {
         Iterator var5 = this.c.iterator();

         while(true) {
            com.aspose.cells.a.f.zh var6;
            do {
               do {
                  do {
                     if (!var5.hasNext()) {
                        return;
                     }

                     var6 = (com.aspose.cells.a.f.zh)var5.next();
                  } while(!var3 && !com.aspose.cells.b.a.zv.b(var6.b(), var1));
               } while(var3 && !var6.b().startsWith(var1));
            } while(var4 != null && var6.b().indexOf(var4) != -1);

            if (var3) {
               var2 = var6.b();
            }

            if (!var6.c()) {
               if (var2.endsWith(".rels")) {
                  this.a(var6.b(), var2);
               } else {
                  this.a(var6, var2);
               }
            }
         }
      }
   }

   void a(com.aspose.cells.a.f.zh var1, String var2) throws Exception {
      com.aspose.cells.a.f.zh var3 = this.a.a(var2);
      var3.a(DateTime.getNow());
      this.a.a(var3);
      byte[] var4 = new byte[1024];
      boolean var5 = false;
      com.aspose.cells.b.a.d.zm var6 = this.c.a(var1);

      int var7;
      do {
         var7 = var6.a(var4, 0, var4.length);
         this.a.b(var4, 0, var7);
      } while(var7 > 0);

      var6.a();
      this.a.b();
   }

   void f() throws Exception {
      this.d.getWorksheets().o();
      if (this.d.b != null && this.d.b.b != null) {
         this.c = this.d.b.b.b;
      }

      this.b = new zok(this.d, this.c, this.f, this.g);
      if (this.b.c.size() == 0) {
         throw new CellsException(6, "Dot not support export a wbook without normal worksheet to excel 2007 format");
      } else {
         this.a = new com.aspose.cells.a.f.zj(this.e);
         this.a.b(2);
         this.a.d(0);
      }
   }
}
